$(document).ready(function() {
	
	$(".page-area").children(".option").click(function(event) {
		var leftNow = pxToNum($(".page-c").css("left"));
		var move = parseInt($(".page-list").width());
		console.log(leftNow);
		if ($(this).attr("option") === "front") {
			if (leftNow >= 0) {
				return;
			}
			if ((leftNow+move) <= 0) {
				leftNow += move;
			} else if ((leftNow+move) > 0) {
				leftNow = 0;
			}

			
		} else if ($(this).attr("option") === "back") {
			if ($(".page-c").width() + leftNow > move) {
				leftNow -= move;
			}
		}
		
		$(".page-c").css("left", leftNow+"px");
	});

	$(".page-c").children(".item").click(function(event) {
		$(".page-c").children(".item").each(function(index, target) {
			$(this).removeClass("selected-item");
		});
		$(this).addClass("selected-item");
		
		console.log(typeof(getDataByPage));

		if (typeof(getDataByPage) === "function") {
			
			var pageInfo = {};
			pageInfo.targetPage = $(this).attr("target-page");
			
			getDataByPage(pageInfo);
		}
		
	});
	
	
});
